package com.lzb.party.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lzb.party.entity.Admin;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface AdminMapper extends BaseMapper<Admin> {

    //Mybatis访问数据库

    @Select("Select * from admin")
    List<Admin> findAll();

    @Insert("INSERT into admin(user, pass) values " +
            "(#{user}, #{pass})")
    int insert(Admin admin);

    @Delete("delete from admin where user = #{user}")
    Integer deleteById(@Param("user") Integer user);

    @Select("SELECT * FROM `admin` where user like #{user} limit #{pageNum}, #{pageSize}")
    List<Admin> selectPage(Integer pageNum, Integer pageSize, String user);

    @Select("select count(*) from admin where user like #{user}")
    Integer selectTotal(String user);

    @Select("select count(*) from admin where user like #{user} && pass like #{pass}")
    Integer login(String user, String pass);
}
